package 算法面试;

import com.sun.deploy.util.StringUtils;

/**
 * Created by LiuChang on 2020/1/7
 */
public class 字符串 {

    public boolean isPalindrome(String s) {
        int first = 0;
        int second = s.length() - 1;
        while (first < second) {
            char firstChar = Character.toLowerCase(s.charAt(first));
            char secondChar = Character.toLowerCase(s.charAt(second));
            if (!((firstChar >= '0' && firstChar <= '9')
                    || (firstChar >= 'A' && firstChar <= 'Z')
                    || (firstChar >= 'a' && firstChar <= 'z'))
            ) {
                first++;
            } else if (!((secondChar >= '0' && secondChar <= '9')
                    || (secondChar >= 'A' && secondChar <= 'Z')
                    || (secondChar >= 'a' && secondChar <= 'z'))
            ) {
                second--;
            } else if (firstChar == secondChar) {
                first++;
                second--;
            } else {
                return false;
            }
        }
        return true;

    }

    public static void main(String[] args) {
        字符串 zifu = new 字符串();
        zifu.isPalindrome("0P");
    }
}
